/*
 * Copyright (c) 2017年11月01日  by XuanWu Wireless Technology Co., Ltd 
 *             All rights reserved  
 */
package com.zml.controller;

import com.zml.entity.Blog;
import com.zml.entity.Email;
import com.zml.service.EmailService;
import com.zml.utils.JsonResp;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author <a href="mailto:zhaominglin@wxchina.com">minglin.Zhao</a>
 * @Description
 * @Date 2017/11/1
 * @Version 1.0.0
 */
@Controller
@RequestMapping("/email")
public class EmailController {

    private static final Logger logger = LogManager.getLogger(EmailController.class);

    @Autowired
    private EmailService emailService;

    @RequestMapping(value = "/send",method = RequestMethod.POST)
    @ResponseBody
    private JsonResp sendEmail(@RequestBody Email mail){
        boolean sendEmailResult = emailService.sendEmail(mail.getSubject(),mail.getContent(),mail.getEmailTos()).getResult();
        if(sendEmailResult){
            return JsonResp.success();
        }else {
            return JsonResp.fail("");
        }
    }


}
